package com.rx.dao.sys;

import org.springframework.stereotype.Repository;

import com.rx.dao.BaseDao;
import com.rx.entity.sys.User;

@Repository
public class UserDao extends BaseDao<User, Long> {

	/**
	 * 通过账号获取用户信息
	 * 
	 * @param userName
	 *            账号
	 * @return
	 */
	public User findUserByUserName(String userName) {
		String hql = "from User u where u.userName = ?";
		return (User) createQuery(hql, userName).uniqueResult();
	}

	/**
	 * 通过账号和密码获取用户信息
	 * 
	 * @param userName
	 *            账号
	 * @param passWord
	 *            密码
	 * @return
	 */
	public User findUserByUserNameAndPassWord(String userName, String passWord) {
		String hql = "from User u where u.userName = ? and u.passWord = ?";
		return (User) createQuery(hql, userName, passWord).uniqueResult();
	}

}